package pxn;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class Shezhi extends JFrame{
	/**
	 * 
	 */
	private static final long serialVersionUID = -1312153615321008048L;
	private static Shezhi shezhi=new Shezhi();
	public static Shezhi getShezhi() {
		return shezhi;
	}
	public static String  ADDRESS="";
	public static String  PORT="";
	public static String  MYSQLNAME="";
	public static String  USER="";
	public static String  PASSWORD="";
	Font font1=new Font("楷体", Font.BOLD, 21);
	Font font2=new Font("楷体", Font.BOLD, 15);
	JLabel jLabel1=new JLabel("数据库设置");
	JLabel jLabel2=new JLabel("地址：");
	JLabel jLabel3 = new JLabel("端口：");
	JLabel jLabel4 = new JLabel("数据库名：");
	JTextField jTextField1 = new JTextField();
	JTextField jTextField2 = new JTextField();
	JTextField jTextField3 = new JTextField();
	JButton jButton1 = new JButton("取消");
	JButton jButton2 = new JButton("确认");
	JLabel jLabel5=new JLabel("数据库账号：");
	JLabel jLabel6 = new JLabel("数据库密码：");
	JTextField jTextField4 = new JTextField();
	JTextField jTextField5 = new JTextField();
	
	
	private Shezhi() {
		this.setLocation(300, 300);
		this.setSize(350, 370);
		this.setLayout(null);
		jLabel1.setFont(font1);
		jLabel1.setBounds(110, 20, 150, 30);
		jLabel2.setBounds(40, 70, 80, 30);
		jLabel3.setBounds(40, 110, 80, 30);
		jLabel4.setBounds(40, 150, 80, 30);
		jLabel5.setBounds(40, 190, 80, 30);
		jLabel6.setBounds(40, 230, 80, 30);
		jTextField1.setBounds(130, 70, 150, 30);
		jTextField2.setBounds(130, 110, 150, 30);
		jTextField3.setBounds(130, 150, 150, 30);
		jTextField4.setBounds(130, 190, 150, 30);
		jTextField5.setBounds(130, 230, 150, 30);
		jButton1.setBounds(60, 280, 70, 30);
		jButton2.setBounds(170, 280, 70, 30);
		this.add(jLabel1);
		this.add(jLabel2);
		this.add(jLabel3);
		this.add(jLabel4);
		this.add(jLabel5);
		this.add(jLabel6);
		this.add(jTextField1);
		this.add(jTextField2);
		this.add(jTextField3);
		this.add(jTextField4);
		this.add(jTextField5);
		this.add(jButton1);
		this.add(jButton2);
		//获取数据
		Pz pz=Pz.getPz();
		pz.getKey();
		if (Pz.ADDRESS==0&Pz.PORT==0&Pz.MYSQLNAME==0&Pz.USER==0&Pz.PASSWORD==0) {
			pz.setKeyD();
			pz.set();
			ADDRESS="localhost";
			PORT="3306";
			MYSQLNAME="mysql";
			USER="root";
			PASSWORD="123456";
		}
		jTextField1.setText(ADDRESS);
		jTextField2.setText(PORT);
		jTextField3.setText(MYSQLNAME);
		jTextField4.setText(USER);
		jTextField5.setText(PASSWORD);
		jButton1.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO 自动生成的方法存根
				
			}
		});
		jButton2.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO 自动生成的方法存根
				ADDRESS=jTextField1.getText();
				PORT=jTextField2.getText();
				MYSQLNAME=jTextField3.getText();
				USER=jTextField4.getText();
				PASSWORD=jTextField5.getText();
				
				
				
			}
		});
	}
	
}
